import  axios  from "@/utils/request";

const api = {
  user: "/api/user",
  role: "/api/role",
  service: "/api/service",
  permission: "/api/permission",
  permissionNoPager: "/api/permission/no-pager"
};

export default api;

//post
export function postAction(url, parameter) {

  return axios({
    url: url,
    method: "post",
    data: parameter
  });
}

//post method= {post | put}
export function httpAction(url, parameter, method) {
  return axios({
    url: url,
    method: method,
    data: parameter
  });
}

//put
export function putAction(url, parameter) {
  return axios({
    url: url,
    method: "put",
    data: parameter
  });
}

//get
export function getAction(url, parameter) {
  return axios({
    url: url,
    method: "get",
    params: parameter
  });
}

//deleteAction
export function deleteAction(url, parameter) {
  return axios({
    url: url,
    method: "delete",
    params: parameter
  });
}
/**
 * 获取文件访问路径
 * @param avatar
 * @param imgerver
 * @param str
 * @returns {*}
 */
export function getFileAccessHttpUrl(avatar, imgerver, subStr) {
  if (avatar && avatar.indexOf(subStr) != -1) {
    return avatar
  } else {
    return imgerver + '/' + avatar
  }
}